package src.list;

import java.util.*;

/**
 * @author starsea
 * @date 2024-08-14 13:33
 */

public class Test {
    public static void main(String[] args) {
        SingleLinkedList singleLinkedList=new SingleLinkedList();
        singleLinkedList.addLast(1);
        singleLinkedList.addLast(2);
        singleLinkedList.addLast(3);
        singleLinkedList.addLast(4);
        singleLinkedList.addLast(5);
        singleLinkedList.addLast(6);
        //遍历打印
        singleLinkedList.display();
        //头插
        singleLinkedList.addFirst(123);
        singleLinkedList.display();
        //尾插
        singleLinkedList.addLast(987);
        singleLinkedList.display();
        //指定位置插入
        singleLinkedList.addIndex(0,65);

        singleLinkedList.display();
        //查询是否包含
        System.out.println(singleLinkedList.contains(66));
        //删除第一次出现的65
        singleLinkedList.remove(65);
        singleLinkedList.display();
        //删除所有出现987
        singleLinkedList.addIndex(0,987);
        singleLinkedList.addIndex(0,987);
        singleLinkedList.removeAllKey(987);
        singleLinkedList.display();
        //输出链表的长度
        System.out.println(singleLinkedList.size());
        //clear
        singleLinkedList.clear();
        singleLinkedList.display();


    }
    public static void main1(String[] args) {
        MyArrayList list = new MyArrayList();
        ArrayList<Integer> list1=new ArrayList<>();
        list1.add(88);

        list.add(1);
        list.add(2);
        list.add(3);
        list.disPlay();
        list.deleteByPost(0);
        list.disPlay();
        list.add(0, 5);
        list.disPlay();
        System.out.println(list.contains(3));
        String str1="welcome to bite";
        String str2="come";
        List list2=ways(str1,str2);
        Iterator it=list2.iterator();
        while (it.hasNext())
        {
            System.out.print(it.next());
        }

    }

    /**
     * 练习题
     */
   static List<Character> ways(String str1, String str2)
    {
        Set<Character> set=new HashSet<>();
        for(char c:str2.toCharArray())
        {
            set.add(c);
        }
        List<Character> list=new ArrayList<>();
        for(int i=0;i<str1.length();i++)
        {
            String ch=str1.charAt(i)+"";
            if(!str2.contains(ch))
            {
                list.add(str1.charAt(i));
            }
        }
        return list;
    }
}
